//
//  ViewController.m
//  01加法计算器
//
//  Created by 黄际衡 on 2017/8/28.
//  Copyright © 2017年 黄际衡. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
- (IBAction)compute;



@property (weak, nonatomic) IBOutlet UITextField *txtNum1;

@property (weak, nonatomic) IBOutlet UITextField *txtNum2;

@property (weak, nonatomic) IBOutlet UILabel *lblResult;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (IBAction)compute {
    
    //1.获取用户输入
    int n1=self.txtNum1.text.intValue;
    int n2=self.txtNum2.text.intValue;
    
    //2.计算和
    int result=n1+n2;
    
    //3.显示结果
    self.lblResult.text=[NSString stringWithFormat:@"%d",result];
    
    //4.将键盘叫回去
    //方法1:[self.txtNum2 resignFirstResponder];
    //方法二：停止编辑 键盘弹回
    [self.view endEditing:YES];
    
    

    
    
    
}
@end
